"""
登录页面
"""
from time import sleep

from selenium.webdriver.common.by import By
from PAGE.base_page import BasePage
from TOOLS.utils import human_like_slide
class LoginPage(BasePage):
    #元素定位器
    username_locator = (By.XPATH,'//*[@id="app"]/div/div[1]/form/div[1]/div/div/input')
    password_locator = (By.XPATH,'//*[@id="app"]/div/div[1]/form/div[2]/div/div/input')
    label_locator = (By.CLASS_NAME,'dv_handler')
    btn_locator = (By.XPATH,'//*[@id="app"]/div/div[1]/form/div[5]/div')

    def input_username(self, username):
        self.driver.find_element(*self.username_locator).send_keys(username)

    #输入密码
    def input_password(self, password):
        self.driver.find_element(*self.password_locator).send_keys(password)

    # 拖拽按钮
    def drag_btn(self):
        a = self.driver.find_element(*self.label_locator)
        human_like_slide(a,350)
    #点击确定
    def click_btn(self):
        self.driver.find_element(*self.btn_locator).click()

    #登录页面
    """完成登录操作"""
    def login(self,username,password):
        self.open()
        self.input_username(username)
        self.input_password(password)
        self.drag_btn()
        self.click_btn()
        sleep(2)


